package com.hgf.helper.mybatisplusdemo.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.hgf.helper.mybatisplus.helper.MyMetaObjectHandler;
import com.hgf.helper.mybatisplus.helper.SqlCostInterceptor;
import com.hgf.helper.mybatisplus.inject.HSqlInject;
import com.hgf.helper.mybatisplus.join.JoinHelperStartHook;
import com.hgf.helper.mybatisplus.salves.SalvesReadAutoConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@MapperScan("com.hgf.helper.mybatisplusdemo.db.mapper")
@Import({JoinHelperStartHook.class, SalvesReadAutoConfig.class})
public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

    @Bean
    public SqlCostInterceptor sqlCostInterceptor() {
        return new SqlCostInterceptor();
    }

    @Bean
    public MyMetaObjectHandler myMetaObjectHandler() {
        return new MyMetaObjectHandler();
    }

    @Bean
    public HSqlInject hSqlInject() {
        return new HSqlInject();
    }


}